<?php /*
In a place, there are 65 people. Among 65, 15 engineers, 15 doctor, 
15 teacher, 20 children. Now a valid group contains 2 engineers, 1 doctor, 
2 teacher, 2 children.
a) Tell me how many valid groups can be created.
b) Tell me how many people left behind (unable to create valid group) 
*/?>

<?php
$total = 65;
$eng = 15;
$doc = 15;
$tec = 15;
$child = 20;
$numbervalidgroup = 0;
$numberpersonbygroup =7;
for($i=$total;$i>=7;$i=$i-$numberpersonbygroup)
{
//echo "eng".$eng.'<br>';
//echo "doc".$doc.'<br>';
//echo "teach".$tec.'<br>';
//echo "child".$child.'<br>';
if($eng>2 && $doc>1 && $tec>2 && $child>2)
{
$numbervalidgroup++;
$eng=$eng-2;
$doc=$doc-1;
$tec=$tec-2;
$child=$child-2;
}

}
echo "Valid groups = ".$numbervalidgroup.'<br>';
$left = $total -($numbervalidgroup*$numberpersonbygroup);
echo "People left behind = ".$left;

?>